{% extends "management/base.html" %}
{% load static %}
{% block title %}用户管理{% endblock %}



{% block content %}
    <div class="box">
        <div class="box-header with-border col-md-offset-1">
            <h3 class="box-title">用户列表</h3>
        </div>
        <!-- /.box-header -->

        <div class="box-body">
            <div style="margin-bottom: 10px">
                <form class="form-inline user-query">
                    <div class="form-group col-md-offset-1">
                        <label for="">用户名</label>
                        <input type="text" class="form-control" name="username" value="{{ username }}">
                    </div>

{#                    <div class="form-group">#}
{#                        <label for="">分组</label>#}
{#                        <select name="group" id="" class="form-control">#}
{#                            <option value="">所有</option>#}
{#                            {% for group in groups %}#}
{#                                <option {% if groups__id == group.id %}selected{% endif %}#}
{#                                        value="{{ group.id }}">{{ group.name }}</option>#}
{#                            {% endfor %}#}
{#                        </select>#}
{#                    </div>#}
{##}
{#                    <div class="form-group">#}
{#                        <label for="">是否员工</label>#}
{#                        <select name="is_staff" id="" class="form-control">#}
{#                            <option value="">所有</option>#}
{#                            <option {% if is_staff is True %}selected{% endif %} value="1">是</option>#}
{#                            <option {% if is_staff is False %}selected{% endif %} value="0">否</option>#}
{#                        </select>#}
{#                    </div>#}
{##}
{#                    <div class="form-group">#}
{#                        <label for="">是否管理员</label>#}
{#                        <select name="is_superuser" id="" class="form-control">#}
{#                            <option value="">所有</option>#}
{#                            <option {% if is_superuser is True %}selected{% endif %} value="1">是</option>#}
{#                            <option {% if is_superuser is False %}selected{% endif %} value="0">否</option>#}
{#                        </select>#}
{#                    </div>#}
{##}
{#                    <button type="button" class="btn btn-info query">查询</button>#}
{#                    <button type="button" class="btn btn-default reset">重置</button>#}
                </form>
            </div>

            <table class="table table-bordered col-md-offset-1">
                <tbody>
                <tr>
                    <th>#</th>
                    <th>用户名</th>
                    <th>email</th>
                    <th>是否可用</th>
                    <th>是否员工</th>
                    <th>是否管理员</th>
                </tr>
                {% for user in users %}
                    <tr>
                        <td style="width: 40px"><a href="#" data-id="{{ user.id }}">{{ forloop.counter }}</a></td>
                        <td>{{ user.username }}</td>
                        <td>{{ user.email }}</td>
                        <td>{% if user.is_active %}是{% else %}否{% endif %}</td>
                        <td>{% if user.is_staff %}是{% else %}否{% endif %}</td>
                        <td>{% if user.is_superuser %}是{% else %}否{% endif %}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>


        </div>

        <!-- 分页 -->
        <div id="pages" class="text-center" >
        <nav>
            <ul class="pagination">
                <li class="step-links">
                {% if users.has_previous %}
                    <a class='active' href="?page={{ users.previous_page_number }}">上一页</a>
                {% endif %}

                <span class="current">
                    Page {{ users.number }} of {{ users.paginator.num_pages }}</span>

                {% if users.has_next %}
                    <a class='active' href="?page={{ users.next_page_number }}">下一页</a>
                {% endif %}
                </li>
            </ul>
        </nav>
        </div>

    </div>
{% endblock %}


{% block script %}
    <script src="{% static 'js/jquery.min.js'%}"></script>
    <script src="{% static 'js/user_list.js' %}"></script>
{% endblock %}
